﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Admin.Controls
{
    public partial class ViewSanGiaoDich : System.Web.UI.UserControl
    {
        DataTable dt;
        public int Employee_ID;
        public int TinhThanhPho_ID;
        public int QuanHuyen_ID;
        public int Category_ID1;
        public int LoaiTinRao_ID;
        public int DonVi_ID;
        public string Employee_Name;
        public string TinhThanhPho_Name;
        public string QuanHuyen_Name;
        public string Category_Name;
        public string LoaiTinRao_Name;
        public string DonVi_Name;



        public string SanGiaoDich_TieuDe;
        public string SanGiaoDich_Title;
        public string SanGiaoDich_Image;
        public string SanGiaoDich_Alt;
        public string SanGiaoDich_DienTich;
        public string SanGiaoDich_KhuVuc;
        public string SanGiaoDich_CauTruc;
        public string SanGiaoDich_TTChiTiet;
        public string SanGiaoDich_GiaBan;
        public string SanGiaoDich_LienHeChiTiet;
        public string SanGiaoDich_Website;
        public string SanGiaoDich_Ten;
        public string SanGiaoDich_DiaChi;
        public string SanGiaoDich_Email;
        public string SanGiaoDich_MayBan;
        public string SanGiaoDich_DiDong;
        public string SanGiaoDich_TenCongTy;
        public string SanGiaoDich_Date;
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            dt = DAL.DCollector.DBCollector.Instance.StoredSelectTableWhereID("tbl_SanGiaoDich", "SanGiaoDich_ID", id.ToString());
            Employee_ID = Convert.ToInt32(dt.Rows[0]["Employee_ID"].ToString());
            TinhThanhPho_ID = Convert.ToInt32(dt.Rows[0]["TinhThanhPho_ID"].ToString());
            QuanHuyen_ID = Convert.ToInt32(dt.Rows[0]["QuanHuyen_ID"].ToString());
            Category_ID1 = Convert.ToInt32(dt.Rows[0]["Category_ID1"].ToString());
            LoaiTinRao_ID = Convert.ToInt32(dt.Rows[0]["LoaiTinRao_ID"].ToString());
            DonVi_ID = Convert.ToInt32(dt.Rows[0]["DonVi_ID"].ToString());
            SanGiaoDich_TieuDe = dt.Rows[0]["SanGiaoDich_TieuDe"].ToString();
            SanGiaoDich_Title = dt.Rows[0]["SanGiaoDich_Title"].ToString();
            SanGiaoDich_Image = dt.Rows[0]["SanGiaoDich_Image"].ToString();
            SanGiaoDich_Alt = dt.Rows[0]["SanGiaoDich_Alt"].ToString();
            SanGiaoDich_DienTich = dt.Rows[0]["SanGiaoDich_DienTich"].ToString();
            SanGiaoDich_KhuVuc = dt.Rows[0]["SanGiaoDich_KhuVuc"].ToString();
            SanGiaoDich_CauTruc = dt.Rows[0]["SanGiaoDich_CauTruc"].ToString();
            SanGiaoDich_TTChiTiet = dt.Rows[0]["SanGiaoDich_TTChiTiet"].ToString();
            SanGiaoDich_GiaBan = dt.Rows[0]["SanGiaoDich_GiaBan"].ToString();
            SanGiaoDich_LienHeChiTiet = dt.Rows[0]["SanGiaoDich_LienHeChiTiet"].ToString();
            SanGiaoDich_Website = dt.Rows[0]["SanGiaoDich_Website"].ToString();
            SanGiaoDich_Ten = dt.Rows[0]["SanGiaoDich_Ten"].ToString();
            SanGiaoDich_DiaChi = dt.Rows[0]["SanGiaoDich_DiaChi"].ToString();
            SanGiaoDich_Email = dt.Rows[0]["SanGiaoDich_Email"].ToString();
            SanGiaoDich_MayBan = dt.Rows[0]["SanGiaoDich_MayBan"].ToString();
            SanGiaoDich_DiDong = dt.Rows[0]["SanGiaoDich_DiDong"].ToString();
            SanGiaoDich_TenCongTy = dt.Rows[0]["SanGiaoDich_TenCongTy"].ToString();
            SanGiaoDich_Date = dt.Rows[0]["SanGiaoDich_Date"].ToString();



            dt = DAL.DCollector.DBCollector.Instance.StoredSelectTableWhereID("tbl_Employee", "Employee_ID", Employee_ID.ToString());
            Employee_Name = dt.Rows[0]["Employee_FullName"].ToString();
            dt = DAL.DCollector.DBCollector.Instance.StoredSelectTableWhereID("tbl_TinhThanhPho", "TinhThanhPho_ID", TinhThanhPho_ID.ToString());
            TinhThanhPho_Name = dt.Rows[0]["TinhThanhPho_Ten"].ToString();
            dt = DAL.DCollector.DBCollector.Instance.StoredSelectTableWhereID("tbl_QuanHuyen", "QuanHuyen_ID", QuanHuyen_ID.ToString());
            QuanHuyen_Name = dt.Rows[0]["QuanHuyen_Ten"].ToString();
            dt = DAL.DCollector.DBCollector.Instance.StoredSelectTableWhereID("tbl_LoaiTinRao", "LoaiTinRao_ID", LoaiTinRao_ID.ToString());
            LoaiTinRao_Name = dt.Rows[0]["LoaiTinRao_TieuDe"].ToString();
            dt = DAL.DCollector.DBCollector.Instance.StoredSelectTableWhereID("tbl_DonVi", "DonVi_ID", DonVi_ID.ToString());
            DonVi_Name = dt.Rows[0]["DonVi_Name"].ToString();

            txtTomTat.Text = SanGiaoDich_CauTruc;
            txtChiTiet.Text = SanGiaoDich_TTChiTiet;

        }

        protected void lbtDelete_Click(object sender, EventArgs e)
        {
            int id2 = Convert.ToInt32(Request.QueryString["id"]);
            DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_TienIch", "SanGiaoDich_ID", id2.ToString());
            DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_SanGiaoDich", "SanGiaoDich_ID", id2.ToString());
            Response.Redirect("/Admin/Index.aspx?panel=1&sub=7");
        }
    }
}